{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Using TensorFlow backend.\n",
      "C:\\Users\\aravind reddy\\anaconda3\\lib\\site-packages\\tensorflow\\python\\framework\\dtypes.py:516: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
      "  _np_qint8 = np.dtype([(\"qint8\", np.int8, 1)])\n",
      "C:\\Users\\aravind reddy\\anaconda3\\lib\\site-packages\\tensorflow\\python\\framework\\dtypes.py:517: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
      "  _np_quint8 = np.dtype([(\"quint8\", np.uint8, 1)])\n",
      "C:\\Users\\aravind reddy\\anaconda3\\lib\\site-packages\\tensorflow\\python\\framework\\dtypes.py:518: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
      "  _np_qint16 = np.dtype([(\"qint16\", np.int16, 1)])\n",
      "C:\\Users\\aravind reddy\\anaconda3\\lib\\site-packages\\tensorflow\\python\\framework\\dtypes.py:519: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
      "  _np_quint16 = np.dtype([(\"quint16\", np.uint16, 1)])\n",
      "C:\\Users\\aravind reddy\\anaconda3\\lib\\site-packages\\tensorflow\\python\\framework\\dtypes.py:520: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
      "  _np_qint32 = np.dtype([(\"qint32\", np.int32, 1)])\n",
      "C:\\Users\\aravind reddy\\anaconda3\\lib\\site-packages\\tensorflow\\python\\framework\\dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
      "  np_resource = np.dtype([(\"resource\", np.ubyte, 1)])\n",
      "C:\\Users\\aravind reddy\\anaconda3\\lib\\site-packages\\tensorboard\\compat\\tensorflow_stub\\dtypes.py:541: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
      "  _np_qint8 = np.dtype([(\"qint8\", np.int8, 1)])\n",
      "C:\\Users\\aravind reddy\\anaconda3\\lib\\site-packages\\tensorboard\\compat\\tensorflow_stub\\dtypes.py:542: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
      "  _np_quint8 = np.dtype([(\"quint8\", np.uint8, 1)])\n",
      "C:\\Users\\aravind reddy\\anaconda3\\lib\\site-packages\\tensorboard\\compat\\tensorflow_stub\\dtypes.py:543: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
      "  _np_qint16 = np.dtype([(\"qint16\", np.int16, 1)])\n",
      "C:\\Users\\aravind reddy\\anaconda3\\lib\\site-packages\\tensorboard\\compat\\tensorflow_stub\\dtypes.py:544: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
      "  _np_quint16 = np.dtype([(\"quint16\", np.uint16, 1)])\n",
      "C:\\Users\\aravind reddy\\anaconda3\\lib\\site-packages\\tensorboard\\compat\\tensorflow_stub\\dtypes.py:545: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
      "  _np_qint32 = np.dtype([(\"qint32\", np.int32, 1)])\n",
      "C:\\Users\\aravind reddy\\anaconda3\\lib\\site-packages\\tensorboard\\compat\\tensorflow_stub\\dtypes.py:550: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
      "  np_resource = np.dtype([(\"resource\", np.ubyte, 1)])\n"
     ]
    }
   ],
   "source": [
    "import keras\n",
    "from keras.models import Sequential\n",
    "from keras.layers import Dense\n",
    "from keras.layers import Convolution2D\n",
    "from keras.layers import MaxPooling2D\n",
    "from keras.layers import Flatten"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "WARNING:tensorflow:From C:\\Users\\aravind reddy\\anaconda3\\lib\\site-packages\\keras\\backend\\tensorflow_backend.py:74: The name tf.get_default_graph is deprecated. Please use tf.compat.v1.get_default_graph instead.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "model=Sequential()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "WARNING:tensorflow:From C:\\Users\\aravind reddy\\anaconda3\\lib\\site-packages\\keras\\backend\\tensorflow_backend.py:517: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.\n",
      "\n",
      "WARNING:tensorflow:From C:\\Users\\aravind reddy\\anaconda3\\lib\\site-packages\\keras\\backend\\tensorflow_backend.py:4138: The name tf.random_uniform is deprecated. Please use tf.random.uniform instead.\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\aravind reddy\\anaconda3\\lib\\site-packages\\ipykernel_launcher.py:1: UserWarning: Update your `Conv2D` call to the Keras 2 API: `Conv2D(32, (3, 3), input_shape=(64, 64, 3..., activation=\"relu\")`\n",
      "  \"\"\"Entry point for launching an IPython kernel.\n"
     ]
    }
   ],
   "source": [
    "model.add(Convolution2D(32,3,3,input_shape=(64,64,3),activation='relu'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\aravind reddy\\anaconda3\\lib\\site-packages\\ipykernel_launcher.py:1: UserWarning: Update your `Conv2D` call to the Keras 2 API: `Conv2D(32, (3, 3), input_shape=(64, 64, 3..., activation=\"relu\")`\n",
      "  \"\"\"Entry point for launching an IPython kernel.\n"
     ]
    }
   ],
   "source": [
    "model.add(Convolution2D(32,3,3,input_shape=(64,64,3),activation='relu'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "WARNING:tensorflow:From C:\\Users\\aravind reddy\\anaconda3\\lib\\site-packages\\keras\\backend\\tensorflow_backend.py:3976: The name tf.nn.max_pool is deprecated. Please use tf.nn.max_pool2d instead.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "model.add(MaxPooling2D(pool_size=(2,2)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "model.add(MaxPooling2D(pool_size=(2,2)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "model.add(Flatten())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\aravind reddy\\anaconda3\\lib\\site-packages\\ipykernel_launcher.py:1: UserWarning: Update your `Dense` call to the Keras 2 API: `Dense(activation=\"relu\", units=300, kernel_initializer=\"uniform\")`\n",
      "  \"\"\"Entry point for launching an IPython kernel.\n"
     ]
    }
   ],
   "source": [
    "model.add(Dense(init='uniform',activation='relu',units=300))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\aravind reddy\\anaconda3\\lib\\site-packages\\ipykernel_launcher.py:1: UserWarning: Update your `Dense` call to the Keras 2 API: `Dense(activation=\"relu\", units=300, kernel_initializer=\"uniform\")`\n",
      "  \"\"\"Entry point for launching an IPython kernel.\n"
     ]
    }
   ],
   "source": [
    "model.add(Dense(init='uniform',activation='relu',units=300))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\aravind reddy\\anaconda3\\lib\\site-packages\\ipykernel_launcher.py:1: UserWarning: Update your `Dense` call to the Keras 2 API: `Dense(activation=\"relu\", units=300, kernel_initializer=\"uniform\")`\n",
      "  \"\"\"Entry point for launching an IPython kernel.\n"
     ]
    }
   ],
   "source": [
    "model.add(Dense(init='uniform',activation='relu',units=300))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\aravind reddy\\anaconda3\\lib\\site-packages\\ipykernel_launcher.py:1: UserWarning: Update your `Dense` call to the Keras 2 API: `Dense(units=6, activation=\"sigmoid\", kernel_initializer=\"uniform\")`\n",
      "  \"\"\"Entry point for launching an IPython kernel.\n"
     ]
    }
   ],
   "source": [
    "model.add(Dense(init='uniform',units=6,activation='sigmoid'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "WARNING:tensorflow:From C:\\Users\\aravind reddy\\anaconda3\\lib\\site-packages\\keras\\optimizers.py:790: The name tf.train.Optimizer is deprecated. Please use tf.compat.v1.train.Optimizer instead.\n",
      "\n",
      "WARNING:tensorflow:From C:\\Users\\aravind reddy\\anaconda3\\lib\\site-packages\\keras\\backend\\tensorflow_backend.py:3295: The name tf.log is deprecated. Please use tf.math.log instead.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "model.compile(loss='categorical_crossentropy',optimizer='adam',metrics=['accuracy'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "from keras.preprocessing.image import ImageDataGenerator\n",
    "train_datagen=ImageDataGenerator(rescale=1./255,shear_range=0.2,zoom_range=0.2,horizontal_flip=True)\n",
    "test_datagen=ImageDataGenerator(rescale=1./255)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Found 537 images belonging to 6 classes.\n",
      "Found 171 images belonging to 6 classes.\n"
     ]
    }
   ],
   "source": [
    "x_train=train_datagen.flow_from_directory(r'F:\\Internship\\CNN\\dataset\\train dataset',target_size=(64,64),batch_size=32,class_mode='categorical')\n",
    "x_test=test_datagen.flow_from_directory(r'F:\\Internship\\CNN\\dataset\\test dataset',target_size=(64,64),batch_size=32,class_mode='categorical')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "WARNING:tensorflow:From C:\\Users\\aravind reddy\\anaconda3\\lib\\site-packages\\tensorflow\\python\\ops\\math_grad.py:1250: add_dispatch_support.<locals>.wrapper (from tensorflow.python.ops.array_ops) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "Use tf.where in 2.0, which has the same broadcast rule as np.where\n",
      "WARNING:tensorflow:From C:\\Users\\aravind reddy\\anaconda3\\lib\\site-packages\\keras\\backend\\tensorflow_backend.py:986: The name tf.assign_add is deprecated. Please use tf.compat.v1.assign_add instead.\n",
      "\n",
      "Epoch 1/100\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\aravind reddy\\anaconda3\\lib\\site-packages\\PIL\\Image.py:960: UserWarning: Palette images with Transparency expressed in bytes should be converted to RGBA images\n",
      "  \"Palette images with Transparency expressed in bytes should be \"\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "16/16 [==============================] - 13s 832ms/step - loss: 1.7846 - acc: 0.2246 - val_loss: 1.7881 - val_acc: 0.2375\n",
      "Epoch 2/100\n",
      "16/16 [==============================] - 12s 742ms/step - loss: 1.7717 - acc: 0.2641 - val_loss: 1.7635 - val_acc: 0.2590\n",
      "Epoch 3/100\n",
      "16/16 [==============================] - 12s 748ms/step - loss: 1.7735 - acc: 0.2513 - val_loss: 1.7636 - val_acc: 0.2446\n",
      "Epoch 4/100\n",
      "16/16 [==============================] - 13s 805ms/step - loss: 1.7646 - acc: 0.2582 - val_loss: 1.7549 - val_acc: 0.2662\n",
      "Epoch 5/100\n",
      "16/16 [==============================] - 12s 744ms/step - loss: 1.7542 - acc: 0.2714 - val_loss: 1.8707 - val_acc: 0.2518\n",
      "Epoch 6/100\n",
      "16/16 [==============================] - 11s 698ms/step - loss: 1.7487 - acc: 0.2865 - val_loss: 1.7624 - val_acc: 0.2878\n",
      "Epoch 7/100\n",
      "16/16 [==============================] - 11s 707ms/step - loss: 1.7366 - acc: 0.2793 - val_loss: 1.7647 - val_acc: 0.2313\n",
      "Epoch 8/100\n",
      "16/16 [==============================] - 11s 661ms/step - loss: 1.7295 - acc: 0.3012 - val_loss: 1.9825 - val_acc: 0.2734\n",
      "Epoch 9/100\n",
      "16/16 [==============================] - 12s 725ms/step - loss: 1.7066 - acc: 0.2967 - val_loss: 1.7267 - val_acc: 0.2446\n",
      "Epoch 10/100\n",
      "16/16 [==============================] - 12s 748ms/step - loss: 1.6647 - acc: 0.3101 - val_loss: 1.9028 - val_acc: 0.2806\n",
      "Epoch 11/100\n",
      "16/16 [==============================] - 13s 798ms/step - loss: 1.6574 - acc: 0.3105 - val_loss: 1.6610 - val_acc: 0.3094\n",
      "Epoch 12/100\n",
      "16/16 [==============================] - 13s 821ms/step - loss: 1.6400 - acc: 0.3418 - val_loss: 1.8091 - val_acc: 0.2950\n",
      "Epoch 13/100\n",
      "16/16 [==============================] - 15s 935ms/step - loss: 1.5704 - acc: 0.3745 - val_loss: 1.9962 - val_acc: 0.2562\n",
      "Epoch 14/100\n",
      "16/16 [==============================] - 12s 772ms/step - loss: 1.5958 - acc: 0.3282 - val_loss: 1.9870 - val_acc: 0.3237\n",
      "Epoch 15/100\n",
      "16/16 [==============================] - 12s 779ms/step - loss: 1.5282 - acc: 0.3912 - val_loss: 1.8004 - val_acc: 0.3309\n",
      "Epoch 16/100\n",
      "16/16 [==============================] - 12s 742ms/step - loss: 1.5045 - acc: 0.4078 - val_loss: 1.7961 - val_acc: 0.3094\n",
      "Epoch 17/100\n",
      "16/16 [==============================] - 13s 794ms/step - loss: 1.4578 - acc: 0.4108 - val_loss: 2.1176 - val_acc: 0.3597\n",
      "Epoch 18/100\n",
      "16/16 [==============================] - 13s 820ms/step - loss: 1.4246 - acc: 0.4355 - val_loss: 1.9349 - val_acc: 0.3237\n",
      "Epoch 19/100\n",
      "16/16 [==============================] - 12s 752ms/step - loss: 1.4110 - acc: 0.4323 - val_loss: 1.9630 - val_acc: 0.3750\n",
      "Epoch 20/100\n",
      "16/16 [==============================] - 12s 723ms/step - loss: 1.3588 - acc: 0.4700 - val_loss: 2.3917 - val_acc: 0.3237\n",
      "Epoch 21/100\n",
      "16/16 [==============================] - 11s 685ms/step - loss: 1.3374 - acc: 0.4611 - val_loss: 2.0561 - val_acc: 0.3597\n",
      "Epoch 22/100\n",
      "16/16 [==============================] - 13s 813ms/step - loss: 1.2318 - acc: 0.5149 - val_loss: 2.5237 - val_acc: 0.3309\n",
      "Epoch 23/100\n",
      "16/16 [==============================] - 12s 723ms/step - loss: 1.2572 - acc: 0.5325 - val_loss: 2.4872 - val_acc: 0.3741\n",
      "Epoch 24/100\n",
      "16/16 [==============================] - 11s 702ms/step - loss: 1.2174 - acc: 0.5217 - val_loss: 2.7715 - val_acc: 0.3453\n",
      "Epoch 25/100\n",
      "16/16 [==============================] - 11s 664ms/step - loss: 1.2421 - acc: 0.4919 - val_loss: 2.2781 - val_acc: 0.3500\n",
      "Epoch 26/100\n",
      "16/16 [==============================] - 11s 690ms/step - loss: 1.1306 - acc: 0.5569 - val_loss: 2.3723 - val_acc: 0.4388\n",
      "Epoch 27/100\n",
      "16/16 [==============================] - 12s 736ms/step - loss: 1.1147 - acc: 0.5556 - val_loss: 2.1755 - val_acc: 0.3022\n",
      "Epoch 28/100\n",
      "16/16 [==============================] - 11s 684ms/step - loss: 1.0740 - acc: 0.5750 - val_loss: 3.0697 - val_acc: 0.3022\n",
      "Epoch 29/100\n",
      "16/16 [==============================] - 11s 704ms/step - loss: 1.0828 - acc: 0.5820 - val_loss: 2.4569 - val_acc: 0.4245\n",
      "Epoch 30/100\n",
      "16/16 [==============================] - 12s 722ms/step - loss: 1.0533 - acc: 0.5932 - val_loss: 3.3065 - val_acc: 0.3453\n",
      "Epoch 31/100\n",
      "16/16 [==============================] - 12s 735ms/step - loss: 0.9985 - acc: 0.6146 - val_loss: 2.3541 - val_acc: 0.3937\n",
      "Epoch 32/100\n",
      "16/16 [==============================] - 10s 618ms/step - loss: 0.9543 - acc: 0.6410 - val_loss: 2.9123 - val_acc: 0.3309\n",
      "Epoch 33/100\n",
      "16/16 [==============================] - 12s 754ms/step - loss: 0.8982 - acc: 0.6601 - val_loss: 2.4239 - val_acc: 0.4173\n",
      "Epoch 34/100\n",
      "16/16 [==============================] - 11s 681ms/step - loss: 0.8823 - acc: 0.6817 - val_loss: 2.3670 - val_acc: 0.4173\n",
      "Epoch 35/100\n",
      "16/16 [==============================] - 11s 692ms/step - loss: 0.8609 - acc: 0.6758 - val_loss: 2.8871 - val_acc: 0.3453\n",
      "Epoch 36/100\n",
      "16/16 [==============================] - 11s 712ms/step - loss: 0.8625 - acc: 0.6801 - val_loss: 3.3909 - val_acc: 0.3669\n",
      "Epoch 37/100\n",
      "16/16 [==============================] - 12s 722ms/step - loss: 0.7971 - acc: 0.6783 - val_loss: 2.1838 - val_acc: 0.4875\n",
      "Epoch 38/100\n",
      "16/16 [==============================] - 11s 682ms/step - loss: 0.7550 - acc: 0.7213 - val_loss: 2.3625 - val_acc: 0.4820\n",
      "Epoch 39/100\n",
      "16/16 [==============================] - 10s 643ms/step - loss: 0.7277 - acc: 0.7295 - val_loss: 2.4710 - val_acc: 0.4460\n",
      "Epoch 40/100\n",
      "16/16 [==============================] - 11s 688ms/step - loss: 0.7411 - acc: 0.7364 - val_loss: 2.2468 - val_acc: 0.5827\n",
      "Epoch 41/100\n",
      "16/16 [==============================] - 10s 635ms/step - loss: 0.6172 - acc: 0.7785 - val_loss: 2.3810 - val_acc: 0.4317\n",
      "Epoch 42/100\n",
      "16/16 [==============================] - 11s 697ms/step - loss: 0.5965 - acc: 0.8098 - val_loss: 3.0987 - val_acc: 0.4245\n",
      "Epoch 43/100\n",
      "16/16 [==============================] - 10s 637ms/step - loss: 0.6499 - acc: 0.7746 - val_loss: 2.5449 - val_acc: 0.4375\n",
      "Epoch 44/100\n",
      "16/16 [==============================] - 11s 708ms/step - loss: 0.5286 - acc: 0.8108 - val_loss: 3.1152 - val_acc: 0.4532\n",
      "Epoch 45/100\n",
      "16/16 [==============================] - 11s 672ms/step - loss: 0.5533 - acc: 0.7799 - val_loss: 3.5371 - val_acc: 0.4317\n",
      "Epoch 46/100\n",
      "16/16 [==============================] - 11s 702ms/step - loss: 0.4741 - acc: 0.8244 - val_loss: 2.2349 - val_acc: 0.4892\n",
      "Epoch 47/100\n",
      "16/16 [==============================] - 12s 726ms/step - loss: 0.5267 - acc: 0.8288 - val_loss: 2.9206 - val_acc: 0.4964\n",
      "Epoch 48/100\n",
      "16/16 [==============================] - 12s 729ms/step - loss: 0.4332 - acc: 0.8611 - val_loss: 2.9739 - val_acc: 0.5108\n",
      "Epoch 49/100\n",
      "16/16 [==============================] - 10s 635ms/step - loss: 0.4312 - acc: 0.8508 - val_loss: 2.9624 - val_acc: 0.4562\n",
      "Epoch 50/100\n",
      "16/16 [==============================] - 11s 675ms/step - loss: 0.3305 - acc: 0.8890 - val_loss: 2.9715 - val_acc: 0.4748\n",
      "Epoch 51/100\n",
      "16/16 [==============================] - 11s 667ms/step - loss: 0.3988 - acc: 0.8435 - val_loss: 3.9708 - val_acc: 0.3237\n",
      "Epoch 52/100\n",
      "16/16 [==============================] - 11s 676ms/step - loss: 0.3312 - acc: 0.8848 - val_loss: 3.6891 - val_acc: 0.4820\n",
      "Epoch 53/100\n",
      "16/16 [==============================] - 11s 674ms/step - loss: 0.3550 - acc: 0.8763 - val_loss: 3.3476 - val_acc: 0.4964\n",
      "Epoch 54/100\n",
      "16/16 [==============================] - 10s 654ms/step - loss: 0.3067 - acc: 0.8949 - val_loss: 3.1826 - val_acc: 0.5108\n",
      "Epoch 55/100\n",
      "16/16 [==============================] - 11s 659ms/step - loss: 0.2902 - acc: 0.9007 - val_loss: 3.4971 - val_acc: 0.4625\n",
      "Epoch 56/100\n",
      "16/16 [==============================] - 11s 705ms/step - loss: 0.2822 - acc: 0.9100 - val_loss: 3.2891 - val_acc: 0.5108\n",
      "Epoch 57/100\n",
      "16/16 [==============================] - 11s 670ms/step - loss: 0.3006 - acc: 0.9022 - val_loss: 3.2645 - val_acc: 0.4604\n",
      "Epoch 58/100\n",
      "16/16 [==============================] - 11s 682ms/step - loss: 0.2675 - acc: 0.9124 - val_loss: 3.5596 - val_acc: 0.4892\n",
      "Epoch 59/100\n",
      "16/16 [==============================] - 11s 687ms/step - loss: 0.2483 - acc: 0.9192 - val_loss: 3.2235 - val_acc: 0.5180\n",
      "Epoch 60/100\n",
      "16/16 [==============================] - 11s 685ms/step - loss: 0.3450 - acc: 0.8963 - val_loss: 2.8881 - val_acc: 0.4820\n",
      "Epoch 61/100\n",
      "16/16 [==============================] - 11s 669ms/step - loss: 0.2329 - acc: 0.9261 - val_loss: 3.2132 - val_acc: 0.4750\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch 62/100\n",
      "16/16 [==============================] - 11s 676ms/step - loss: 0.2384 - acc: 0.9144 - val_loss: 3.1413 - val_acc: 0.5252\n",
      "Epoch 63/100\n",
      "16/16 [==============================] - 11s 675ms/step - loss: 0.2080 - acc: 0.9300 - val_loss: 3.6260 - val_acc: 0.4964\n",
      "Epoch 64/100\n",
      "16/16 [==============================] - 11s 702ms/step - loss: 0.2484 - acc: 0.9169 - val_loss: 3.3632 - val_acc: 0.4173\n",
      "Epoch 65/100\n",
      "16/16 [==============================] - 11s 673ms/step - loss: 0.2457 - acc: 0.9252 - val_loss: 3.3559 - val_acc: 0.4820\n",
      "Epoch 66/100\n",
      "16/16 [==============================] - 11s 701ms/step - loss: 0.1647 - acc: 0.9467 - val_loss: 3.2244 - val_acc: 0.5180\n",
      "Epoch 67/100\n",
      "16/16 [==============================] - 11s 666ms/step - loss: 0.1594 - acc: 0.9408 - val_loss: 3.9368 - val_acc: 0.4375\n",
      "Epoch 68/100\n",
      "16/16 [==============================] - 11s 684ms/step - loss: 0.1738 - acc: 0.9417 - val_loss: 3.3043 - val_acc: 0.5036\n",
      "Epoch 69/100\n",
      "16/16 [==============================] - 11s 690ms/step - loss: 0.2257 - acc: 0.9258 - val_loss: 3.5897 - val_acc: 0.4532\n",
      "Epoch 70/100\n",
      "16/16 [==============================] - 11s 712ms/step - loss: 0.2596 - acc: 0.9110 - val_loss: 3.6726 - val_acc: 0.3957\n",
      "Epoch 71/100\n",
      "16/16 [==============================] - 11s 680ms/step - loss: 0.1798 - acc: 0.9374 - val_loss: 3.6692 - val_acc: 0.5180\n",
      "Epoch 72/100\n",
      "16/16 [==============================] - 11s 665ms/step - loss: 0.1415 - acc: 0.9501 - val_loss: 3.4800 - val_acc: 0.5108\n",
      "Epoch 73/100\n",
      "16/16 [==============================] - 11s 708ms/step - loss: 0.1659 - acc: 0.9350 - val_loss: 3.4527 - val_acc: 0.5188\n",
      "Epoch 74/100\n",
      "16/16 [==============================] - 11s 689ms/step - loss: 0.1663 - acc: 0.9511 - val_loss: 3.8841 - val_acc: 0.5468\n",
      "Epoch 75/100\n",
      "16/16 [==============================] - 11s 667ms/step - loss: 0.2012 - acc: 0.9423 - val_loss: 3.1931 - val_acc: 0.5396\n",
      "Epoch 76/100\n",
      "16/16 [==============================] - 11s 709ms/step - loss: 0.1537 - acc: 0.9526 - val_loss: 4.4240 - val_acc: 0.4604\n",
      "Epoch 77/100\n",
      "16/16 [==============================] - 11s 675ms/step - loss: 0.1551 - acc: 0.9501 - val_loss: 3.6572 - val_acc: 0.4676\n",
      "Epoch 78/100\n",
      "16/16 [==============================] - 10s 649ms/step - loss: 0.1284 - acc: 0.9506 - val_loss: 3.6119 - val_acc: 0.5324\n",
      "Epoch 79/100\n",
      "16/16 [==============================] - 10s 654ms/step - loss: 0.1559 - acc: 0.9609 - val_loss: 3.8150 - val_acc: 0.5062\n",
      "Epoch 80/100\n",
      "16/16 [==============================] - 11s 658ms/step - loss: 0.1478 - acc: 0.9609 - val_loss: 3.8049 - val_acc: 0.5108\n",
      "Epoch 81/100\n",
      "16/16 [==============================] - 11s 715ms/step - loss: 0.1055 - acc: 0.9629 - val_loss: 3.2960 - val_acc: 0.4964\n",
      "Epoch 82/100\n",
      "16/16 [==============================] - 12s 777ms/step - loss: 0.1286 - acc: 0.9540 - val_loss: 3.9549 - val_acc: 0.4820\n",
      "Epoch 83/100\n",
      "16/16 [==============================] - 12s 737ms/step - loss: 0.1278 - acc: 0.9584 - val_loss: 4.3041 - val_acc: 0.4604\n",
      "Epoch 84/100\n",
      "16/16 [==============================] - 11s 691ms/step - loss: 0.1675 - acc: 0.9428 - val_loss: 4.3479 - val_acc: 0.4676\n",
      "Epoch 85/100\n",
      "16/16 [==============================] - 11s 680ms/step - loss: 0.1056 - acc: 0.9579 - val_loss: 4.0508 - val_acc: 0.5000\n",
      "Epoch 86/100\n",
      "16/16 [==============================] - 11s 693ms/step - loss: 0.1812 - acc: 0.9355 - val_loss: 3.0224 - val_acc: 0.5612\n",
      "Epoch 87/100\n",
      "16/16 [==============================] - 11s 680ms/step - loss: 0.1032 - acc: 0.9702 - val_loss: 3.9089 - val_acc: 0.4532\n",
      "Epoch 88/100\n",
      "16/16 [==============================] - 11s 657ms/step - loss: 0.0981 - acc: 0.9721 - val_loss: 4.0156 - val_acc: 0.4604\n",
      "Epoch 89/100\n",
      "16/16 [==============================] - 11s 667ms/step - loss: 0.0647 - acc: 0.9780 - val_loss: 4.0108 - val_acc: 0.4388\n",
      "Epoch 90/100\n",
      "16/16 [==============================] - 10s 651ms/step - loss: 0.0616 - acc: 0.9746 - val_loss: 4.5128 - val_acc: 0.4820\n",
      "Epoch 91/100\n",
      "16/16 [==============================] - 12s 740ms/step - loss: 0.0671 - acc: 0.9805 - val_loss: 4.3016 - val_acc: 0.5125\n",
      "Epoch 92/100\n",
      "16/16 [==============================] - 11s 665ms/step - loss: 0.0802 - acc: 0.9746 - val_loss: 4.6756 - val_acc: 0.4532\n",
      "Epoch 93/100\n",
      "16/16 [==============================] - 11s 672ms/step - loss: 0.0821 - acc: 0.9805 - val_loss: 4.5623 - val_acc: 0.5108\n",
      "Epoch 94/100\n",
      "16/16 [==============================] - 10s 646ms/step - loss: 0.0800 - acc: 0.9824 - val_loss: 3.8382 - val_acc: 0.4748\n",
      "Epoch 95/100\n",
      "16/16 [==============================] - 11s 718ms/step - loss: 0.0577 - acc: 0.9838 - val_loss: 4.0359 - val_acc: 0.5540\n",
      "Epoch 96/100\n",
      "16/16 [==============================] - 11s 685ms/step - loss: 0.0657 - acc: 0.9824 - val_loss: 4.2537 - val_acc: 0.4532\n",
      "Epoch 97/100\n",
      "16/16 [==============================] - 11s 663ms/step - loss: 0.0299 - acc: 0.9922 - val_loss: 4.6457 - val_acc: 0.4562\n",
      "Epoch 98/100\n",
      "16/16 [==============================] - 11s 660ms/step - loss: 0.0248 - acc: 0.9961 - val_loss: 4.4237 - val_acc: 0.4964\n",
      "Epoch 99/100\n",
      "16/16 [==============================] - 11s 698ms/step - loss: 0.1443 - acc: 0.9590 - val_loss: 4.2488 - val_acc: 0.4460\n",
      "Epoch 100/100\n",
      "16/16 [==============================] - 11s 658ms/step - loss: 0.0933 - acc: 0.9805 - val_loss: 4.5996 - val_acc: 0.4317\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<keras.callbacks.History at 0x12d00409888>"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model.fit_generator(x_train,steps_per_epoch = 16 , epochs = 100 , validation_data = x_test,validation_steps = 5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "model.save(\"build.h5\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [],
   "source": [
    "from keras.models import load_model\n",
    "from keras.preprocessing import image\n",
    "import numpy as np "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "model = load_model(\"build.h5\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [],
   "source": [
    "img = image.load_img(\"asystole.jpg\",target_size= (64,64))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = image.img_to_array(img)\n",
    "x = np.expand_dims(x,axis = 0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1, 64, 64, 3)"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [],
   "source": [
    "pred = model.predict_classes(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([5], dtype=int64)"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pred"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'Accelerated Idioventricular Rhythm': 0, 'Bundle Branch Block': 1, 'Normal Sinus Rhythm': 2, 'Premature Ventricular Complex': 3, 'Ventricular Tachycardia Torsade de Pointes': 4, 'asystole': 5}\n"
     ]
    }
   ],
   "source": [
    "print(x_train.class_indices)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
